﻿using BlawkayEngine.Debug;
using BlawkayEngine.Input;
using BlawkayEngine.ScreenSystem;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;

namespace BlawkayEngine
{
    public static class GameInfo
    {

        #region Methods

        /// <summary>
        /// Loads the Blockey Essentials to the game. Call in the Game Manager's Load method
        /// </summary>
        /// <param name="oGameManager">The Game Manager</param>
        public static void LoadAll(Game oGame)
        {
            _Game = oGame;
            _SquareTexture = Game.Content.Load<Texture2D>("Essentials\\Pics\\Square");
            _CircleTexture = Game.Content.Load<Texture2D>("Essentials\\Pics\\Circle");

            SpriteBatch oSpriteBatch = new SpriteBatch(Game.GraphicsDevice);
            SpriteFont oDebugFont = Game.Content.Load<SpriteFont>("Essentials\\Fonts\\Debug");
            _DebugHelper = new DebugHelper(oSpriteBatch, oDebugFont, _SquareTexture);

            GameInfo.KeyboardInput = new KeyboardInput();

            Resolution = new Rectangle(0, 0, 1280, 720);

            IsDebug = true;
        }

        /// <summary>
        /// Begins the updating of the current frame
        /// </summary>
        public static void BeginUpdate()
        {
            GameInfo.KeyboardInput.Update();
        }

        /// <summary>
        /// Updates the current Screen Manager
        /// </summary>
        public static void ScreenManagerUpdate()
        {
            ScreenManager.Update();
        }

        /// <summary>
        /// Ends the updating of the current frame
        /// </summary>
        public static void EndUpdate()
        {

        }

        /// <summary>
        /// Starts the drawing of the current frame
        /// </summary>
        public static void BeginDraw()
        {
            // Clears the screen to draw
            Game.GraphicsDevice.Clear(Color.DarkSlateGray);
        }

        /// <summary>
        /// Ends the drawing of the current frame
        /// </summary>
        public static void EndDraw()
        {
            // Draws Debug Information
            if (IsDebug)
            {
                Debug.DrawDebugMessages();
            }
        }

        #endregion

        #region Properties

        // Game
        public static Game Game
        {
            get { return _Game; }
        }
        public static Rectangle Resolution
        {
            get { return _Resolution; }
            set { _Resolution = value; }
        }
        public static GameTime GameTime
        {
            get { return _GameTime; }
            set { _GameTime = value; }
        }

        // Screen Manager
        public static ScreenManager ScreenManager
        {
            get { return _ScreenManager; }
            set { _ScreenManager = value; }
        }

        // Graphics
        public static Texture2D Texture_Square
        {
            get { return _SquareTexture; }
        }
        public static Texture2D Texture_Circle
        {
            get { return _CircleTexture; }
        }

        // Game States
        public static MainState MainState
        {
            get { return _MainState; }
            set
            {
                _MainState = value;
            }
        }
        public static MenuState MenuState
        {
            get { return _MenuState; }
            set
            {
                _MenuState = value;
            }
        }

        // Debug
        public static DebugHelper Debug
        {
            get { return _DebugHelper; }
        }
        public static bool IsDebug
        {
            get;
            set;
        }

        // Input
        public static KeyboardInput KeyboardInput
        {
            get { return _KeyboardInput; }
            set { _KeyboardInput = value; }
        }

        #endregion

        #region Fields

        private static Game _Game;
        private static ScreenManager _ScreenManager;
        private static Texture2D _SquareTexture;
        private static Texture2D _CircleTexture;
        private static MainState _MainState;
        private static MenuState _MenuState;
        private static DebugHelper _DebugHelper;
        private static Rectangle _Resolution;
        private static GameTime _GameTime;
        private static KeyboardInput _KeyboardInput;

        #endregion

    }
}
